using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration; using Sispe.Entities;

namespace Sispe.Repository.Mapping
{
    public class REFERENCIAMap : EntityTypeConfiguration<REFERENCIA>
    {
        public REFERENCIAMap()
        {
            // Primary Key
            this.HasKey(t => t.IdReferencia);

            // Properties
            this.Property(t => t.IdReferencia)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.Parentesco)
                .HasMaxLength(350);

            // Table & Column Mappings
            this.ToTable("REFERENCIA");
            this.Property(t => t.IdReferencia).HasColumnName("IdReferencia");
            this.Property(t => t.IdPersona).HasColumnName("IdPersona");
            this.Property(t => t.Parentesco).HasColumnName("Parentesco");

            // Relationships
            this.HasRequired(t => t.PERSONA)
                .WithMany(t => t.REFERENCIAs)
                .HasForeignKey(d => d.IdPersona)
                .WillCascadeOnDelete(false);

        }
    }
}
